package com.treasure.mall.biz.service.core.community;

import com.treasure.mall.biz.base.SearchableCrudService;
import com.treasure.mall.biz.entity.community.CommunityArticlePO;
import com.treasure.mall.biz.entity.community.CommunityCommentLikePO;
import com.treasure.mall.biz.entity.community.CommunityCommentPO;
import com.treasure.mall.biz.entity.user.UserPO;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

public interface CommunityCommentService extends SearchableCrudService<CommunityCommentPO, Long> {
    Map<String, CommunityCommentLikePO> findByUser(Long userId, List<CommunityCommentPO> pos);

    /**
     * 评论
     *
     * @param parentId
     * @param rootId
     * @param articlePO
     * @param content
     * @param userPO
     * @return
     */
    @Transactional
    CommunityCommentPO comment(long parentId, long rootId, CommunityArticlePO articlePO, String content, UserPO userPO);

    /**
     * 回复
     *
     * @param commentId
     * @param content
     * @param userPO
     */
    @Transactional
    CommunityCommentPO reply(Long commentId, String content, UserPO userPO);

    /**
     * 点赞或取消
     *
     * @param commentId
     * @param userPO
     */
    @Transactional
    boolean likeToggle(long commentId, UserPO userPO);

    /**
     * 用户是否喜欢
     *
     * @param commentId
     * @param userId
     * @return
     */
    boolean isUserLiked(Long commentId, Long userId);
}
